package com.jackykeke.opengldemo.view;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;

import com.jackykeke.opengldemo.filter.BaseFilter;
import com.jackykeke.opengldemo.renderer.FilterRenderer;

public class GLFuckView extends GLSurfaceView {

    private FilterRenderer mGLRender;

    public GLFuckView(Context context) {
        this(context, null);
    }

    public GLFuckView(Context context, AttributeSet attrs) {
        super(context, attrs);

        setupSurfaceView();
    }

    private void setupSurfaceView() {
        //设置版本
        setEGLContextClientVersion(3);
        mGLRender = new FilterRenderer();
        setRenderer(mGLRender);

        try {
            requestRender();
        } catch (Exception e) {

        }

    }


    public void setFilter(BaseFilter baseFilter) {
        if (baseFilter != null)
            mGLRender.setFilter(baseFilter);
    }
}
